{%- extends "bootstrap/base.html" -%}

{%- block metas -%}
    {{ super() }}
    <meta charset="utf-8" >
{%- endblock metas -%}

{%- block styles -%}
    {{ super() }}
    <style type="text/css">
        ul.nav li{padding:0px 10px}
    </style>
{%- endblock styles -%}

{%- block navbar -%}
    <nav class="navbar navbar-inverse" role="navigation">
        <div class="navbar-header">
            <a class="navbar-brand" href="{{ url_for('main.index') }}">MyBlog2.0</a>
        </div>
        <div>
            <ul class="nav navbar-nav">
                <li><a href="{{ url_for('main.index') }}">主页</a></li>
                {% if current_user.is_authenticated %}
                    <li><a href="{{ url_for('main.user',username=current_user.username) }}">{{ current_user.username }}</a></li>
                {% endif %}
            </ul>
            <ul class="nav navbar-nav navbar-right">
                {% if current_user.is_authenticated %}
                    <li><a href="{{ url_for('auth.logout') }}">退出</a></li>
                {%- else -%}
                    <li><a href="{{ url_for('auth.login') }}">登录</a></li>
                {% endif %}
            </ul>
        </div>
    </nav>
{%- endblock navbar -%}

{% block content -%}
    {% block msg -%}
        <div class="msg">
            {%- with messages = get_flashed_messages() %}
              {%- if messages %}
                <ul class=flashes>
                {%- for message in messages %}
                    <div class="alert alert-danger alert-dismissable">
                       <button type="button" class="close" data-dismiss="alert"
                          aria-hidden="true">
                          &times;
                       </button>
                       {{ message }}
                    </div>
                {%- endfor %}
                </ul>
              {%- endif %}
            {%- endwith %}
        </div>
    {%- endblock msg %}
{%- endblock content %}